home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / web / noweb / src / c / match.c < prev    next >
C/C++ Source or Header  |  1995-02-24  |  677b  |  21 lines

  1. #line 10 "match.nw"
  2. #include <string.h>
  3. #include "match.h"
  4. static int matches(char *line, char *search) {
  5.     return !strncmp(line,search,strlen(search));
  6. }
  7. int is_keyword(char *line, char *keyword) {
  8.     char low_at_sign = '@';
  9.     return *line==low_at_sign && matches(line+1,keyword) && 
  10.            (line[strlen(keyword)+1]==' ' || line[strlen(keyword)+1]=='\n');
  11. }
  12. int is_begin(char *line, char *type) {
  13.     return is_keyword(line,"begin") && matches(line+1+6,type);
  14. }
  15. int is_end(char *line, char *type) {
  16.     return is_keyword(line,"end") && matches (line+1+4,type);
  17. }
  18. int is_index(char *line, char *type) {
  19.     return is_keyword(line,"index") && matches(line+1+6,type);
  20. }
  21.